package com.ciwong.epaper.modules.epaper.ui;

import android.content.Intent;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.android.volley.TimeoutError;
import com.ciwong.epaper.R;
import com.ciwong.epaper.application.EApplication;
import com.ciwong.epaper.modules.bookstore.bean.PublishWorkContent;
import com.ciwong.epaper.modules.epaper.adapter.ChooseWordExAdapter;
import com.ciwong.epaper.modules.epaper.bean.FollowReadWordDetailBean;
import com.ciwong.epaper.modules.epaper.bean.FollowReadWordDetails;
import com.ciwong.epaper.modules.epaper.bean.ResourceContent;
import com.ciwong.epaper.modules.epaper.dao.EpaperDao;
import com.ciwong.epaper.modules.me.bean.FollowReadWordDetailBeans;
import com.ciwong.epaper.util.BaseExtCallBack;
import com.ciwong.epaper.util.IntentFlag;
import com.ciwong.epaper.util.RequestCode;
import com.ciwong.libs.utils.NetworkUtils;
import com.ciwong.mobilelib.i.BaseCallBack;
import com.ciwong.mobilelib.ui.BaseActivity;
import com.ciwong.mobilelib.utils.ToastUtil;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 编辑作业内容 选单词页面
 */
public class ChooseWordActivity extends BaseActivity {

    //报听写单词内容
    private List<FollowReadWordDetails> followReadWordDetailsList = new ArrayList<>();

    //全选按钮
    private CheckBox choose_work_content;

    private ExpandableListView choose_word_ex_list;

    private TextView choose_word_detail_text;

    private RelativeLayout choose_word_finish;

    //选择朗读方式下拉框
    private Spinner choose_read_style;
    //选择朗读次数下拉框
    private Spinner choose_read_times;

    private String versionId;

    private String resourceUrl;

    private List<FollowReadWordDetailBean> followReadWordDetailBeanList = new ArrayList<>();

    private MediaPlayer mediaPlayer;

    private ChooseWordExAdapter chooseWordExAdapter;

    private FollowReadWordDetailBeans followReadWordDetailBeans = new FollowReadWordDetailBeans();
    private String requirementContent;
    //资源名
    private String resourceName;

    //父目录versionId
    private String parentVersionId;

    //资源内容
    private ResourceContent resourceContent;

    private int moduleId;

    private String resourceType;

    /**
     * 作业分数
     */
    private float workScore;

    //单词总数
    private int wordCountAll;

    private int groupCountAll;
    //作业内容页面跳转过来 true 全选 false 选部分
    private Boolean isChecked;
    //作业总时长
    private double workLong;
    //选中单词所需作业时长
    private double chooseWordWorkLong;

    private int oldTime = 1;
    //选中单词总数
    private double checkCountAll;
    private int requestCode;
    //跟读次数
    private int readTime;
    //跟读方式 跟读 朗读 背诵
    private String readStyle;
    private TextView choose_word_work_long_text;


    @Override
    protected int setView() {
        return R.layout.activity_dictation_choose_content;
    }

    @Override
    protected void findViews() {
        choose_work_content = findViewById(R.id.choose_work_content);
        choose_word_ex_list = findViewById(R.id.choose_word_ex_list);
        choose_word_detail_text = findViewById(R.id.choose_word_detail_text);
        choose_word_finish = findViewById(R.id.choose_word_finish);
        choose_read_times = findViewById(R.id.choose_read_times);
        choose_read_style = findViewById(R.id.choose_read_style);
        choose_word_work_long_text = findViewById(R.id.choose_word_work_long_text);

        choose_word_finish.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        choose_read_style.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                String[] stringArray = ChooseWordActivity.this.getResources().getStringArray(R.array.read_style);
                readStyle = stringArray[i];
            }

            @Override
            public void onNothingSelected(AdapterView<?> adapterView) {

            }
        });

        choose_read_times.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                String[] stringArray = ChooseWordActivity.this.getResources().getStringArray(R.array.read_times);
                readTime = i + 1;
                chooseWordWorkLong = chooseWordWorkLong / oldTime * readTime;
                workLong = workLong / oldTime * readTime;
                oldTime = readTime;
                int workRefLong = ((int) (Math.ceil(chooseWordWorkLong / 60)));
                SpannableStringBuilder chooseCountText = new SpannableStringBuilder("已选择 " + (int) checkCountAll + " 个单词");
                SpannableStringBuilder chooseWorkLongText = new SpannableStringBuilder("预计 " + (int) workRefLong + " 分钟");
                ForegroundColorSpan GreenSpan = new ForegroundColorSpan(Color.parseColor("#5ce191"));

                if (checkCountAll < 10) {
                    chooseCountText.setSpan(GreenSpan, 4, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                } else {
                    chooseCountText.setSpan(GreenSpan, 4, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                }

                if (workRefLong >= 100) {
                    chooseWorkLongText.setSpan(GreenSpan, 3, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                } else if (workRefLong < 10) {
                    chooseWorkLongText.setSpan(GreenSpan, 3, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                } else {
                    chooseWorkLongText.setSpan(GreenSpan, 3, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
                choose_word_detail_text.setText(chooseCountText);
                choose_word_work_long_text.setText(chooseWorkLongText);
            }

            @Override
            public void onNothingSelected(AdapterView<?> adapterView) {

            }
        });
        choose_work_content.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (!compoundButton.isPressed()) {
                    return;
                }
                if (b) {
                    choose_work_content.setChecked(true);
                    choose_work_content.setSelected(true);
                    followReadWordDetailBeans.setCheckGroupCount(groupCountAll);
                    List<FollowReadWordDetailBean> followReadWordDetailBeanList = followReadWordDetailBeans.getFollowReadWordDetailBeanList();
                    for (int i = 0; i < followReadWordDetailBeanList.size(); i++) {
                        FollowReadWordDetailBean followReadWordDetailBean = followReadWordDetailBeanList.get(i);
                        int wordCount = followReadWordDetailBean.getFollowReadWordDetailsList().size();
                        followReadWordDetailBean.setCheckCount(wordCount);
                        List<FollowReadWordDetails> ff = followReadWordDetailBean.getFollowReadWordDetailsList();
                        for (int i1 = 0; i1 < ff.size(); i1++) {
                            ff.get(i1).setIsChecked(true);
                        }
                    }
                    setChooseWordDetail();
                    chooseWordExAdapter.notifyDataSetChanged();
                } else {
                    choose_work_content.setChecked(false);
                    choose_work_content.setSelected(true);
                    followReadWordDetailBeans.setCheckGroupCount(0);
                    List<FollowReadWordDetailBean> followReadWordDetailBeanList = followReadWordDetailBeans.getFollowReadWordDetailBeanList();
                    for (int i = 0; i < followReadWordDetailBeanList.size(); i++) {
                        FollowReadWordDetailBean followReadWordDetailBean = followReadWordDetailBeanList.get(i);
                        followReadWordDetailBean.setCheckCount(0);
                        List<FollowReadWordDetails> ff = followReadWordDetailBean.getFollowReadWordDetailsList();
                        for (int i1 = 0; i1 < ff.size(); i1++) {
                            ff.get(i1).setIsChecked(false);
                        }
                    }
                    setChooseWordDetail();
                    chooseWordExAdapter.notifyDataSetChanged();
                }
            }
        });
    }

    public void setAdapter() {
        chooseWordExAdapter = new ChooseWordExAdapter(followReadWordDetailBeans, ChooseWordActivity.this, mediaPlayer);
        choose_word_ex_list.setAdapter(chooseWordExAdapter);
        for (int i = 0; i < chooseWordExAdapter.getGroupCount(); i++) {
            choose_word_ex_list.expandGroup(i);
        }
    }

    public void setChooseWordDetail() {
        //选中单词总数
        checkCountAll = 0;
        List<FollowReadWordDetailBean> follList = followReadWordDetailBeans.getFollowReadWordDetailBeanList();
        for (int i = 0; i < follList.size(); i++) {
            checkCountAll = checkCountAll + follList.get(i).getCheckCount();
        }
        checkCountAll = Math.ceil(checkCountAll);
        chooseWordWorkLong = workLong / wordCountAll * checkCountAll;
        //有小数点向上取整数
        int workRefLong = ((int) (Math.ceil(chooseWordWorkLong / 60)));
        SpannableStringBuilder chooseCountText = new SpannableStringBuilder("已选择 " + (int) checkCountAll + " 个单词");
        SpannableStringBuilder chooseWorkLongText = new SpannableStringBuilder("预计 " + (int) workRefLong + " 分钟");
        ForegroundColorSpan GreenSpan = new ForegroundColorSpan(Color.parseColor("#5ce191"));

        if (checkCountAll < 10) {
            chooseCountText.setSpan(GreenSpan, 4, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        } else {
            chooseCountText.setSpan(GreenSpan, 4, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if (workRefLong >= 100) {
            chooseWorkLongText.setSpan(GreenSpan, 3, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        } else if (workRefLong < 10) {
            chooseWorkLongText.setSpan(GreenSpan, 3, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        } else {
            chooseWorkLongText.setSpan(GreenSpan, 3, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        choose_word_detail_text.setText(chooseCountText);
        choose_word_work_long_text.setText(chooseWorkLongText);
    }

    /**
     * 获取资源内容统计信息
     *
     * @param parentVersionId
     * @param versionId
     * @param moduleId
     * @param resourceType    资源类型
     */
    public void getResourceStatisticsWeb(final String parentVersionId, final String versionId, int moduleId, final String resourceType) {

        EpaperDao.getInstance().getResourceStatisticsWeb(parentVersionId, versionId, moduleId, resourceType, new BaseExtCallBack(ChooseWordActivity.this, EApplication.getInstance().getUserInfoBase().getUserId() + "") {
            @Override
            public void failed(int errorCode, Object data) {
                super.failed(errorCode, data);
                hideCricleProgress();
                if (data instanceof TimeoutError) {
                    ToastUtil.INSTANCE.toastCenterError(getString(R.string.load_faild_check_net_work));
                }
            }

            @Override
            public void failed(Object data) {
                hideCricleProgress();
                if (!NetworkUtils.isOnline()) {
                    ToastUtil.INSTANCE.toastCenterError(getString(R.string.load_faild_check_net_work));
                    return;
                }
            }

            @Override
            public void success(Object data) {
                if (null != data) {
                    resourceContent = (ResourceContent) data;
                    workScore = resourceContent.getRefScore();
                    if (!versionId.equals("0")) {
                        followreadWordDetails(versionId);
                    } else {
                        followreadWordDetails(parentVersionId);
                    }

                }
            }
        });
    }

    /**
     * 获取单词
     *
     * @param versionid
     */
    public void followreadWordDetails(String versionid) {
        EpaperDao.getInstance().followreadWordDetails(versionid, new BaseCallBack() {
            @Override
            public void failed(int errorCode, Object data) {
                if (data instanceof TimeoutError) {
                    ToastUtil.INSTANCE.toastCenterError(getString(R.string.load_faild_check_net_work));
                } else {
                    ToastUtil.INSTANCE.toastCenterError(getString(R.string.load_faild_try_later));
                }
            }

            @Override
            public void failed(Object data) {
                if (data instanceof TimeoutError) {
                    ToastUtil.INSTANCE.toastCenterError(getString(R.string.load_faild_check_net_work));
                } else {
                    ToastUtil.INSTANCE.toastCenterError(getString(R.string.load_faild_try_later));
                }
            }

            @Override
            public void success(Object data) {
                if (null != data) {
                    followReadWordDetailsList = (List<FollowReadWordDetails>) data;
                    double sentenceTime;
                    int second;
                    if (requestCode == RequestCode.TeaWorkContent.REQ_CODE_TO_CHOOSE_WORD) {
                        second = 20;
                    } else {
                        second = 25;
                    }
                    sentenceTime = 0 == resourceContent.getDefAnswerTime() ? second : resourceContent.getDefAnswerTime();
                    workLong = (int) (Math.ceil(sentenceTime * resourceContent.getItemCount()));
                    wordCountAll = followReadWordDetailsList.size();
                    int listSize = followReadWordDetailsList.size();
                    int count = (listSize % 10 == 0) ? (listSize / 10) : (listSize / 10 + 1);
                    groupCountAll = count;
                    for (int i = 0; i < count; i++) {
                        List<FollowReadWordDetails> folls = new ArrayList<>();
                        List<FollowReadWordDetails> subList = followReadWordDetailsList.subList(i * 10, (i == count - 1) ? listSize : 10 * (i + 1));
                        folls.addAll(subList);
                        FollowReadWordDetailBean followReadWordDetailBean = new FollowReadWordDetailBean();
                        followReadWordDetailBean.setFollowReadWordDetailsList(folls);
                        followReadWordDetailBean.setCheckCount(folls.size());
                        followReadWordDetailBeanList.add(followReadWordDetailBean);
                    }
                    followReadWordDetailBeans = new FollowReadWordDetailBeans();
                    followReadWordDetailBeans.setFollowReadWordDetailBeanList(followReadWordDetailBeanList);
                    if (isChecked) {
                        followReadWordDetailBeans.setCheckGroupCount(count);
                    } else {
                        followReadWordDetailBeans.setCheckGroupCount(0);
                    }
                    List<FollowReadWordDetailBean> followReadWordDetailBeanList = followReadWordDetailBeans.getFollowReadWordDetailBeanList();
                    for (int i = 0; i < followReadWordDetailBeanList.size(); i++) {
                        if (isChecked) {
                            followReadWordDetailBeanList.get(i).setCheckCount(followReadWordDetailBeanList.get(i).getFollowReadWordDetailsList().size());
                        } else {
                            followReadWordDetailBeanList.get(i).setCheckCount(0);
                        }
                        List<FollowReadWordDetails> followReadWordDetailsList = followReadWordDetailBeanList.get(i).getFollowReadWordDetailsList();
                        for (int a = 0; a < followReadWordDetailsList.size(); a++) {
                            if (isChecked) {
                                followReadWordDetailsList.get(a).setIsChecked(true);
                            } else {
                                followReadWordDetailsList.get(a).setIsChecked(false);
                            }

                        }
                    }


                    setAdapter();
                    setChooseWordDetail();
                }
            }
        });
    }


    public void setCheckStatus() {
        //选中单词总数
        /*int checkCountAll = 0;
        for (int i = 0; i < followReadWordDetailBeanList.size(); i++) {
            checkCountAll = checkCountAll+followReadWordDetailBeanList.get(i).getCheckCount();
        }*/
        int checkCountAll = 0;
        int countAll = 0;
        int checkGroupCount = followReadWordDetailBeans.getCheckGroupCount();
        List<FollowReadWordDetailBean> followReadWordDetailBeanList = followReadWordDetailBeans.getFollowReadWordDetailBeanList();
        for (int i = 0; i < followReadWordDetailBeanList.size(); i++) {
            checkCountAll = checkCountAll + followReadWordDetailBeanList.get(i).getCheckCount();
            countAll = countAll + followReadWordDetailBeanList.get(i).getFollowReadWordDetailsList().size();
        }

        if (checkCountAll == countAll) {
            choose_work_content.setChecked(true);
            choose_work_content.setSelected(true);
        } else if (checkCountAll == 0) {
            choose_work_content.setChecked(false);
            choose_work_content.setSelected(true);
        } else {
            choose_work_content.setChecked(true);
            choose_work_content.setSelected(false);
        }
    }

    @Override
    protected void initEvent() {

    }

    @Override
    protected void init() {
        Intent intent = getIntent();
        versionId = intent.getStringExtra(IntentFlag.INTENT_FLAG_VERSION_ID);
        parentVersionId = intent.getStringExtra(IntentFlag.INTENT_FLAG_PARENT_VERSION_ID);
        resourceName = intent.getStringExtra(IntentFlag.INTENT_FLAG_RESOURCE_NAME);
        resourceUrl = intent.getStringExtra(IntentFlag.INTENT_FLAG_RESOURCE_URL);
        isChecked = intent.getBooleanExtra(IntentFlag.INTENT_FLAG_BOOLEAN, true);
        workLong = intent.getIntExtra(IntentFlag.INTENT_FLAG_WORK_LONG, 0);
        requirementContent = intent.getStringExtra(IntentFlag.INTENT_FLAG_READ_TIME);
        moduleId = intent.getIntExtra(IntentFlag.INTENT_FLAG_MODULE_ID, 0);
        resourceType = intent.getStringExtra(IntentFlag.INTENT_FLAG_RESOURCE_TYPE);
        requestCode = intent.getIntExtra(IntentFlag.INTENT_FLAG_REQUEST_CODE_FROM, 10001);
        //类型为报听写不显示 跟读次数及类型不显示
        if (requestCode == RequestCode.TeaWorkContent.REQ_CODE_TO_DICTATION) {
            choose_read_style.setVisibility(View.GONE);
            choose_read_times.setVisibility(View.GONE);
        } else {
            choose_read_style.setVisibility(View.VISIBLE);
            choose_read_times.setVisibility(View.VISIBLE);
        }
        if (null != requirementContent && !"".equals(requirementContent)) {
            JSONObject jsonObject = JSONObject.parseObject(requirementContent);
            oldTime = jsonObject.getIntValue("readtimes");
        }
        choose_read_times.setSelection(oldTime - 1);
        followReadWordDetailBeans = (FollowReadWordDetailBeans) intent.getSerializableExtra(IntentFlag.INTENT_FLAG_OBJ);
        if (isChecked) {
            choose_work_content.setChecked(true);
            choose_work_content.setSelected(true);
        } else {
            choose_work_content.setChecked(false);
            choose_work_content.setSelected(true);
        }
        setTitleText("选择单词");
    }

    @Override
    protected void loadData() {
        if (null != followReadWordDetailBeans && null != followReadWordDetailBeans.getFollowReadWordDetailBeanList() && 0 != followReadWordDetailBeans.getFollowReadWordDetailBeanList().size()) {
            checkCountAll = 0;
            List<FollowReadWordDetailBean> followReadWordDetailBeanList = followReadWordDetailBeans.getFollowReadWordDetailBeanList();
            for (int i = 0; i < followReadWordDetailBeanList.size(); i++) {
                checkCountAll = checkCountAll + followReadWordDetailBeanList.get(i).getCheckCount();
                wordCountAll = wordCountAll + followReadWordDetailBeanList.get(i).getFollowReadWordDetailsList().size();
            }
            setAdapter();
            setChooseWordDetail();
        } else {
            getResourceStatisticsWeb(parentVersionId, versionId, moduleId, resourceType);
        }

    }

    @Override
    protected void onStop() {
        super.onStop();
        if (mediaPlayer != null && mediaPlayer.isPlaying()) {
            Log.e("MediaPlayer ", "停止播放");
            chooseWordExAdapter.stopPlayAnimation();
            mediaPlayer.stop();
            mediaPlayer.release();
            mediaPlayer = null;
        }
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        /*handler.removeCallbacks(startRunnable);
        handler.removeCallbacks(stopRunnable);*/
        if (mediaPlayer != null && mediaPlayer.isPlaying()) {
            Log.e("MediaPlayer ", "停止播放");
            chooseWordExAdapter.stopPlayAnimation();
            mediaPlayer.stop();
            mediaPlayer.release();
            mediaPlayer = null;
        }

    }

    @Override
    public void finish() {
        setChoseWordResult();
        super.finish();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
            setChoseWordResult();
            finish();
            return true;
        } else {
            return super.onKeyDown(keyCode, event);
        }
    }

    public void setChoseWordResult() {
        StringBuffer str = new StringBuffer();

        List<FollowReadWordDetailBean> followReadWordDetailBeanList = followReadWordDetailBeans.getFollowReadWordDetailBeanList();
        for (int i = 0; i < followReadWordDetailBeanList.size(); i++) {
            FollowReadWordDetailBean followReadWordDetailBean = followReadWordDetailBeanList.get(i);
            int checkCount = followReadWordDetailBean.getCheckCount();
            if (checkCount == followReadWordDetailBean.getFollowReadWordDetailsList().size()) {
                List<FollowReadWordDetails> followReadWordDetails = followReadWordDetailBean.getFollowReadWordDetailsList();
                for (int i1 = 0; i1 < followReadWordDetails.size(); i1++) {
                    if (str.length() == 0 || "".equals(str)) {
                        str.append(followReadWordDetails.get(i1).getwId());
                    } else {
                        str.append("," + followReadWordDetails.get(i1).getwId());
                    }

                }
            } else {
                List<FollowReadWordDetails> followReadWordDetails = followReadWordDetailBean.getFollowReadWordDetailsList();
                for (int i1 = 0; i1 < followReadWordDetails.size(); i1++) {
                    if (null == followReadWordDetails.get(i1).getIsChecked() || followReadWordDetails.get(i1).getIsChecked()) {
                        if (str.length() == 0 || "".equals(str)) {
                            str.append(followReadWordDetails.get(i1).getwId());
                        } else {
                            str.append("," + followReadWordDetails.get(i1).getwId());
                        }
                    }
                }
            }
        }
        JSONObject jsonObject = new JSONObject();
        if (requestCode == RequestCode.TeaWorkContent.REQ_CODE_TO_CHOOSE_WORD) {
            //作业要求
            jsonObject.put("readtimes", readTime);
            if (readStyle.equals("跟读")) {
                jsonObject.put("speekingtype", 1);
            } else if (readStyle.equals("朗读")) {
                jsonObject.put("speekingtype", 2);
            }
        }

        PublishWorkContent publishWorkContent = new PublishWorkContent();
        publishWorkContent.setCheckedResource(str.toString());
        publishWorkContent.setTotalQuesNum((int) checkCountAll);
        publishWorkContent.setRequirementContent(jsonObject.toString());
        publishWorkContent.setRefLong((int) chooseWordWorkLong);
        publishWorkContent.setTotalWorkLong((int) workLong);
        publishWorkContent.setFollowReadWordDetailBeans(followReadWordDetailBeans);
        publishWorkContent.setModuleId(moduleId);
        publishWorkContent.setParentVersionId(parentVersionId);
        publishWorkContent.setVersionId(versionId);
        publishWorkContent.setWorkScore(workScore);
        publishWorkContent.setResourceName(resourceName);
        publishWorkContent.setResourceType(resourceType);
        publishWorkContent.setResourceUrl(resourceUrl);

        Intent intent = new Intent();
        intent.putExtra(IntentFlag.INTENT_FLAG_WORD_DETAILS, str.toString());
        intent.putExtra(IntentFlag.INTENT_FLAG_RESOURCE_URL, resourceUrl);
        intent.putExtra(IntentFlag.INTENT_FLAG_RESOURCE_NAME, resourceName);
        intent.putExtra(IntentFlag.INTENT_FLAG_VERSION_ID, versionId);
        intent.putExtra(IntentFlag.INTENT_FLAG_WORK_CONTENT, publishWorkContent);
        if (requestCode == RequestCode.TeaWorkContent.REQ_CODE_TO_CHOOSE_WORD) {
            intent.putExtra(IntentFlag.INTENT_FLAG_JSONOBJECT, jsonObject.toString());
        }
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ, (Serializable) followReadWordDetailBeans);
        intent.putExtra(IntentFlag.INTENT_FLAG_WORK_LONG, (int) chooseWordWorkLong);
        setResult(RESULT_OK, intent);
    }

}
